/**
 * @author tibor kiray
 */

 Ext.namespace('Softab');
 Softab.GetViewPort = function(){
 	var entitiesProxy = new Ext.data.ScriptTagProxy({
    url: 'server/EntitiesTree.php'
	});
	var store = new Ext.data.Store({
	    proxy: entitiesProxy,
	    reader: new Ext.data.JsonReader({
	        id: 'ID',
	        totalProperty: 'totalCount',
	        root: 'Names'
	    }, [{
	        name: 'ID'
	    }, {
	        name: 'name'
	    }])
	});
 	var viewport = new Ext.Viewport({
            layout:'border',
            items:[
                {
                    region:'south',
                    contentEl: 'south',
                    split:true,
                    height: 100,
                    minSize: 100,
                    maxSize: 200,
                    collapsible: true,
                    title:'South',
                    margins:'0 0 0 0',
					collapsed:true
                }, {
                    region:'east',
                    title: 'Diverse',
                    collapsible: true,
                    split:true,
                    width: 225,
                    minSize: 175,
                    maxSize: 400,
                    layout:'fit',
                    margins:'0 5 0 0',
					collapsed:false,
                    items:
                        new Ext.TabPanel({
                            border:false,
                            activeTab:0,
                            tabPosition:'top',
							enableTabScroll: true,
                            items:[
								Softab.PropertiesEditor,
								{
									title:"Entity fields",
									html:'<p>Select an entity to edit it\'s fields</p>',
									tbar: [{
										store: store,
										fieldLabel: 'ComboBox',
										displayField: 'name',
										valueField: 'name',
										typeAhead: true,
										forceSelection: true,
										mode: 'remote',
										triggerAction: 'all',
										selectOnFocus: true,
										editable: true,
										xtype: 'combo',
										width: 130,
										emptyText: 'Entity...',
										listeners: {
											change: function(combo, newValue, oldValue){
											//alert("change");
											//console.log("Old Value: " + oldValue);
											//console.log("New Value: " + newValue);
											},
											select: function(combo, record, index){
												//alert(domainForm.getComponent("selection"));
												domainForm.getComponent("selectedDomain").setRawValue(record.data.ID);
												//alert(domainForm.getComponent("selection").value);
												//console.log(record.data.name);
												//console.log(index);
												//console.log(record.data.ID);
											}
										}
									}
								  ]
								},
								{
	                                html:'<p>Aceasta regiune este in curs de dezvoltare</p>',
	                                title: 'Proprietati',
	                                autoScroll:true
	                            }
								/*,new Ext.grid.PropertyGrid({
                                title: 'Personalizare',
                                closable: true,
								name:'propppp',
								ctCls: 'propgridaaa',
								cls:'propgridaaa',
                                source: {
                                    "(name)": "Properties Grid11",
                                    "grouping": false,
                                    "autoFitColumns": true,
                                    "productionQuality": false,
                                    "created": new Date(Date.parse('10/15/2006')),
                                    "tested": false,
                                    "version": .01,
                                    "borderWidth": 1
                                }
                            })*/
							/*,new Ext.grid.PropertyGrid({
                                title: 'Setari aplicatie',
                                closable: true,
								name:'propppp',
								ctCls: 'propgridaaa',
								cls:'propgridaaa',
                                source: {
                                    "(name)": "Properties Grid11",
                                    "grouping": false,
                                    "autoFitColumns": true,
                                    "productionQuality": false,
                                    "created": new Date(Date.parse('10/15/2006')),
                                    "tested": false,
                                    "version": .01,
                                    "borderWidth": 1
                                }
							})*/
							]
                        })
                 },{
                    region:'west',
                    id:'west-panel',
					contentEl:'west',
                    title:'Navigare',
                    split:true,
                    width: 200,
                    minSize: 175,
                    maxSize: 400,
                    collapsible: true,
                    margins:'0 0 0 5'
                },
                Softab.GetTabsPanel()
             ]
        });
		return viewport;
 }
